function lst = append(lst, lst2)
%APPEND Appends a list to the current list
%
% [ Syntax ]
%  - lst = append(lst, lst2)
%
% [ Description ]
%  - lst = append(lst, lst2) appends the lst2 to the list lst. lst2 can be
%    an sllist object, a cell array, or other collection object / object
%    array.
%
% [ History ]
%   - Created by Dahua Lin, on Jan 5, 2008
%


%% main

l1 = numel(lst);
l2 = numel(lst2);

if l2 > 0
    n = l1 + l2;
    if n > capacity(lst)
        lst = grow(lst, n);
    end
    
    if iscell(lst2)
        lst.items(l1+1:n) = lst2(:);
        
    elseif isa(lst2, 'sllist')
        lst.items(l1+1:n) = lst2.items;               
        
    else
        wlst = sllist(lst2);
        lst.items(l1+1:n) = wlst.item;
    end        
        
    lst.n = n;
end

